package com.example.coroutine.net

import kotlinx.coroutines.CoroutineExceptionHandler
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import kotlin.coroutines.CoroutineContext

class NetCoroutineExceptionHandler: CoroutineExceptionHandler {
    override val key: CoroutineContext.Key<*> = CoroutineExceptionHandler

    override fun handleException(context: CoroutineContext, exception: Throwable) {
        when (exception) {
            is UnknownHostException,
            is SocketException,
            is SocketTimeoutException -> {

            }
            else -> {

            }
        }

        exception.printStackTrace()
    }

}